package com.msg.chestionar.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import com.msg.chestionar.to.IntrebareOptiuneTO;

@NamedQueries( {
	@NamedQuery(name = "IntrebareOptiuneE.findByID", query = "SELECT u FROM IntrebareOptiuneE u WHERE u.id = :id") 
	})
	
@Entity
@Table(name = "T_INTREBARE_OPTIUNE")
@SequenceGenerator(name = "SEQ_INTREBARE_OPTIUNE", sequenceName = "SEQ_INTREBARE_OPTIUNE", allocationSize=1)
public class IntrebareOptiuneE {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_INTREBARE_OPTIUNE")
	private Long id;

	@JoinColumn(name="intrebare_id", nullable=false)
	private IntrebareE intrebareE;

	@Column
	private String text;

	@Column
	private int e_cu_comentariu;
	
	public int getE_cu_comentariu() {
		return e_cu_comentariu;
	}

	public void setE_cu_comentariu(int eCuComentariu) {
		e_cu_comentariu = eCuComentariu;
	}
	
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	public IntrebareE getIntrebareE() {
		return intrebareE;
	}

	public void setIntrebareE(IntrebareE intrebareE) {
		this.intrebareE = intrebareE;
	}

	public IntrebareOptiuneTO getIntrebare_OptiuneTO() {
		IntrebareOptiuneTO intrebare_optiune = new IntrebareOptiuneTO();
		intrebare_optiune.setId(this.id);
		intrebare_optiune.setIntrebare_id(getIntrebareE().getId());
		intrebare_optiune.setText(this.text);
		intrebare_optiune.setE_cu_comentariu(this.e_cu_comentariu == 1);
		return intrebare_optiune;
	}

}
